<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Tabib Apps web | Admin Dashboard Template</title>
    <!-- Base Styling  -->
    <link rel="stylesheet" href="static/css/fonts.css">
    <link rel="stylesheet" href="static/css/style.css">
</head>

<body>
    <div id="main-wrapper" class="show">


        <!-- start logo components -->
        <div class="nav-header">
            <div class="brand-logo">
                <a href="index.html"> <img class="logo-tabib" src="static/picture/download.png" alt=""></a>
                <a href="index.html"><img class="brand-title" src="static/picture/logo.png" alt=""></a>
            </div>
        </div>
        <!-- End logo components -->


        <!-- start section sidebar -->
        <aside class="left-panel nicescroll-box">
            <nav class="navigation">
                <ul class="list-unstyled main-menu">
                    <li class="has-submenu">
                        <a href="index.html">
                            <i class="fas fa-th-large"></i>
                            <span class="nav-label">首页</span>
                        </a>
                    </li>
                    <li class="has-submenu">
                        <a href="#" class="has-arrow mm-collapsed">
                            <i class="fas fa-user-md"></i>
                            <span class="nav-label">医生</span>
                        </a>
                        <ul class="list-unstyled mm-collapse">
                            <li><a href="new-patient.html">查看患者信息</a></li>
                            <li><a href="all-patients.html">所有患者</a></li>
                        </ul>
                    </li>
                    <li class="has-submenu">
                        <a href="#" class="has-arrow mm-collapsed">
                            <i class="fas fa-book-medical"></i>
                            <span class="nav-label">处方</span>
                        </a>
                        <ul class="list-unstyled mm-collapse">
                            <li><a href="new-prescription.html">新处方</a></li>
                            <li><a href="allPrescriptions.html">所有处方</a></li>
                        </ul>
                    </li>
                    <li class="has-submenu">
                        <a href="calendars.html">
                            <i class="fas fa-calendar-alt"></i>
                            <span class="nav-label">排班时间</span>
                        </a>
                    </li>
                </ul>
            </nav>
            <div class="sidebar-widgets">
                <div class="top-sidebar box-shadow mx-25 m-b-30 p-b-20 text-center">
                    <a href="new-appointment.html">
                        <img src="static/picture/appointement.svg" class="side-img" alt="img">
                    </a>
                    <a href="#">
                        <h4 class="text-primary mb-0">Make an Appointments</h4>
                    </a>
                </div>
                <div class="copyright text-center">
                    <p class="mb-0"> Tabib Dashboard</p>
                    <p class="mb-0"> © 2021 </p>
                </div>
            </div>
        </aside>
        <!-- End section sidebar -->


        <!-- start section header -->
        <div class="header">
            <header class="top-head container-fluid">
                <div class="nav-control">
                </div>
                <div class="header-right">
                    <div class="fullscreen notification_dropdown">
                        <div class="full">
                            <a class="text-dark" href="#!" onclick="javascript:toggleFullScreen()">
                                <i class="fas fa-expand"></i>
                            </a>
                        </div>
                    </div>
                    <div class="notification_dropdown">
                        <div class="cart-wrapper">
                            <div class="cart-icon">
                                <a class="cart-control" href="#">
                                    <i class="fas fa-bell"></i>
                                    <div class="pulse-css"></div>
                                </a>
                            </div>
                            <div class="cart-dropdown-form dropdown-container">
                                <div class="form-content">
                                    <div class="widget-media main-scroll nicescroll-box">
                                        <ul class="timeline">
                                            <li>
                                                <h6 class="mb-0">通知</h6>
                                            </li>
                                            <li>
                                                <div class="timeline-panel">
                                                    <div class="media mr-2">
                                                        <img alt="image" src="static/picture/1.jpg">
                                                    </div>
                                                    <div class="media-body">
                                                        <h6 class="mb-1 ">Incoming Message</h6>
                                                        <small class="d-block">29 July 2020 - 02:26 PM</small>
                                                    </div>
                                                </div>
                                            </li>
                                        </ul>
                                    </div>
                                    <a class="all-notification btn btn-primary" href="#">
                                        查看所有通知
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="my-account-wrapper">
                        <div class="account-wrapper">
                            <div class="account-control">
                                <a class="login header-profile" href="#" title="Sign in">
                                    <div class="header-info">
                                        <span id="nickname">Dr Roberts</span>
                                        <small>医生</small>
                                    </div>
                                    <img src="static/picture/client.jpg" alt="people" id="img">
                                </a>
                                <div class="account-dropdown-form dropdown-container">
                                    <div class="form-content">
                                        <a href="chat.html">
                                            <i class="far fa-user"></i>
                                            <span class="ml-2">在线聊天</span>
                                        </a>
                                        <a href="login.html">
                                            <i class="fas fa-sign-in-alt"></i>
                                            <span class="ml-2">退出 </span>
                                        </a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </header>
        </div>
        <!-- End section header -->


        <!-- start section content -->
        <div class="content-body">
            <div class="warper container-fluid">
                <div class="all-patients main_container">
                    <div class="row page-titles mx-0">
                        <div class="col-sm-6 p-md-0">
                            <div class="welcome-text">
                                <h4 class="text-primary">就诊人</h4>
                            </div>
                        </div>
                        <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
                            <ol class="breadcrumb">
                                <li class="breadcrumb-item"><a href="index.html">首页</a></li>
                                <li class="breadcrumb-item active"><a href="javascript:;">查看患者信息</a></li>
                            </ol>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-12">
                            <div class="card">
                                <div class="card-header fix-card">
                                    <div class="row">
                                        <div class="col-8">
                                            <h4 class="card-title"> 所有就诊人</h4>
                                        </div>
                                    </div>
                                </div>
                                <div class="card-body">
                                    <div class="table-responsive">
                                        <table id="example2" class="display nowrap">
                                            <thead>
                                                <tr>
                                                    <th>病历ID</th>
                                                    <th>姓名</th>
                                                    <th>年龄</th>
                                                    <th>手机号</th>
                                                    <th>病因</th>
                                                    <th>性别</th>
                                                    <th>编辑</th>
                                                </tr>
                                            </thead>
                                            <tbody></tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <!-- Modal -->
                        <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
                            <div class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
                                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                    </div>
                                    <div class="modal-body">
                                        ...
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
                                        <button type="button" class="btn btn-primary">保存修改</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- End section content -->


        <!-- start section footer -->
        <div class="footer ">
            <div class="copyright ">
                <p class="mb-0">Copyright &copy; 2021.Company name All rights reserved.<a target="_blank" href="http://www.cssmoban.com/">&#x7F51;&#x9875;&#x6A21;&#x677F;</a></p>
            </div>
        </div>
        <!-- End section footer -->


    </div>


    <!-- Show data patient -->
    <div class="modal fade" id="myModal" tabindex="-1" aria-labelledby="myModalLabel" aria-hidden="true">
        <!-- <div > -->
        <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="myModalLabel"><img class="rounded-circle" width="35" src="static/picture/user1.jpg" alt=""> Tiger Nixon </h5>
                    <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <div class="modal-body">
                    <div class="insertHere"></div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-danger" data-bs-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary">保存修改</button>
                </div>
            </div>
        </div>
    </div>
    <!-- End Show data patient -->


    <!-- Modal -->
   <!-- <div class="modal fade" id="modal-edit" tabindex="-1" aria-labelledby="modal-title-edit-row" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="modal-title-edit-row">Angelica Ramos</h5>
                    <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="basic-form">
                                <form>
                                    <div class="row">
                                        <div class="col-xl-4">
                                            <div class="form-group row widget-3">
                                                <div class="col-lg-12">
                                                    <div class="form-input">
                                                        <label class="labeltest" for="file-ip-1">
                                                            <span> 个人头像 </span>
                                                        </label>
                                                        <input type="file" id="file-ip-1" accept="image/*" onchange="showPreview(event);">
                                                        <div class="preview">
                                                            <img id="file-ip-1-preview" src="https://www.17sucai.com/preview/776298/2021-08-30/tabib/all-patients.html" alt="img">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-xl-4">
                                            <div class="form-group row">
                                                <div class="col-lg-12">
                                                    <input type="text" class="form-control" placeholder="姓名">
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <div class="col-lg-12">
                                                    <input type="text" class="form-control" placeholder="年龄">
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <div class="col-lg-12">
                                                    <input type="email" class="form-control" placeholder="邮箱">
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <div class="col-lg-12">
                                                    <input type="text" class="form-control" placeholder="手机号">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-xl-4">
                                            <div class="form-group row">
                                                <div class="col-lg-12">
                                                    <div class="input-group">
                                                        <input type="text" class="form-control" placeholder="生日">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <div class="input-group">
                                                    <input type="text" class="form-control" placeholder="余额">
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <div class="col-lg-12">
                                                    <select class="form-control form-select">
                                                        <option>性别</option>
                                                        <option>男性</option>
                                                        <option>女性</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <div class="col-lg-12">
                                                    <select class="form-control form-select">
                                                        <option>血型</option>
                                                        <option>A+</option>
                                                        <option>A-</option>
                                                        <option>B+</option>
                                                        <option>B-</option>
                                                        <option>O+</option>
                                                        <option>O-</option>
                                                        <option>AB+</option>
                                                        <option>AB-</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-xl-4"></div>
                                        <div class="col-xl-4">
                                            <div class="form-group row">
                                                <div class="col-lg-12">
                                                    <input type="text" class="form-control" placeholder="体重">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-xl-4">
                                            <div class="form-group row">
                                                <div class="col-lg-12">
                                                    <input type="text" class="form-control" placeholder="身高">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-xl-4">
                                            <div class="form-group">
                                                <div class="col-lg-12">
                                                </div>
                                                <textarea class="form-control" placeholder="地址" rows="4"></textarea>
                                            </div>
                                        </div>
                                        <div class="col-xl-8">
                                            <div class="form-group">
                                                <textarea class="form-control" placeholder="病史" rows="4"></textarea>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-danger" data-bs-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary">保存修改</button>
                </div>
            </div>
        </div>
    </div>-->
    <!--End Modal -->
    <!-- change date and time patient -->
    <div class="modal fade selectRefresh" id="update" tabindex="-1" role="dialog" aria-labelledby="modal-title-addDrug-modal">
        <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="modal-title-addDrug-modal"> 修改处方 </h5>
                    <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <div class="modal-body">
                    <form class="row align-items-start">
                        <div class="row">
                            <div class="form-group">
                                <input type="text" id ="historyId" class="form-control pathogenesis" placeholder="病历ID" readonly="true">
                            </div>
                        </div>
                        <div class="col">
                            <div class="form-group">
                                <input type="text" id ="name" class="form-control pathogenesis" placeholder="姓名" readonly="true">
                            </div>
                        </div>
                        <div class="col">
                            <div class="form-group">
                                <input type="text" id ="pathogenesis" class="form-control pathogenesis" placeholder="病因">
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-danger" data-bs-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="mybtn">保存</button>
                </div>
            </div>
        </div>
    </div>


    <!-- JQuery v3.5.1 -->
    <script src="static/js/jquery.min.js"></script>

    <script src="static/js/jquery-3.6.0.js"></script>

    <!-- popper js -->
    <script src="static/js/popper.min.js"></script>

    <!-- Bootstrap -->
    <script src="static/js/bootstrap.min.js"></script>

    <!-- Moment -->
    <script src="static/js/moment.min.js"></script>

    <!-- Date Range Picker -->
    <script src="static/js/daterangepicker.min.js"></script>

    <!-- Datatable -->
    <script src="static/js/jquery.dataTables.min.js"></script>
    <script src="static/js/init-tdatatable.js"></script>

    <!-- Main Custom JQuery -->
    <script src="static/js/toggleFullScreen.js"></script>
    <script src="static/js/main.js"></script>

</body>
<script>
    $(document).ready(function () {
        $.ajax({
            type: "GET",
            url: "/doctor/session",
            contentType: "application/x-www-form-urlencoded",
            dataType: "json"
        }).done((result)=>{
            if (result.data!=null){
                //登录
                //切换样式
                $(".loginTop").css("display","none");
                $(".collapsible_menu").css("display","block");
                //设置登录用户昵称
                $("#nickname").text(result.data.doctorName);

                $("#img").attr("src",result.data.image);
            }
        }).fail(()=>{
            alert("doctor/session request fail");
        });
        //退出登录
        $(".dropdown-container .form-content a").last().click(function () {
            //发送xhr
            $.getJSON("/doctor/logout",function (result) {
                //切换未登录状态
                $(".loginTop").css("display","block");
                $(".collapsible_menu").css("display","none");
            });
        });
    })
</script>
<script>
    $(document).ready(function () {
        let item = localStorage.getItem("doctorId");
        console.log(item)
        $.ajax({
            type: "get",
            url: "/doctor/getHistoryDetailByDoctorId",
            data:{
                doctorId:item
            },
            contentType: "application/x-www-form-urlencoded",
            dataType: "json"
        }).done((result)=>{
            if (result.data!=null){
                $.each(result.data,function (index,obj){
                    ex2.row.add([obj.historyId,obj.patient.patientName,obj.patient.age,obj.patient.phone,obj.content,obj.patient.gender,'<a data-bs-toggle=\'modal\' data-bs-target=\'#update\' class=\'mr-4\' onclick=\"fill(this)\">\n' +
                    '                                                            <span class=\'fas fa-pencil-alt\'></span>\n' +
                    '                                                        </a>，<a class="mr-4 delet" onclick="delet(this)"><span class="fas fa-trash-alt"></span></a>']);
                    ex2.draw();
                })
            }
        })

    })
</script>
<script>
    function delet(val){
        //这里就是val，别以为写错了，如果写成this会报错：Uncaught SyntaxError: Unexpected token 'this'，这是转过来的参数值的意思
        var value = $(val).parent().parent().find("td");
        let historyId = value.eq(0).text();//病历编号
        console.log(historyId);
        $.ajax({
            type: "get",
            url: "/history/delete",
            data:{
                historyId:historyId
            },
            contentType: "application/x-www-form-urlencoded",
            dataType: "json"
        }).done((result)=>{
            if (result.data == true){
                alert("删除成功")
                location.reload();
            }
        })

    }

    function fill(val){
        var value = $(val).parents("tr").find("td");
        let historyId = value.eq(0).text();//病历编号
        var valu = $(val).parents("tr").find("td");
        let patientName = value.eq(1).text();//病历编号
        console.log(historyId);
        $("#historyId").val(historyId)
        $("#name").val(patientName)
    }

    $(function (){
        $("#mybtn").bind('click',function (){
            $.ajax({
                type: "get",
                url: "/history/update",
                data:{
                    historyId: $("#historyId").val(),
                    historyContent:$("#pathogenesis").val()
                },
                contentType: "application/x-www-form-urlencoded",
                dataType: "json"
            }).done((result)=>{
                if (result.data === true){
                    alert("修改成功")
                    location.reload();
                }
            })
        })
    })
</script>
</html>